package com.AEWMS.Servlet;

import com.AEWMS.Dao.CourseScore;
import com.AEWMS.Service.CourseScoreService;
import com.alibaba.fastjson.JSON;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "FailExamsServlet", urlPatterns = "/FailExamsServlet")
public class FailExamsServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username = request.getParameter("username");
        CourseScoreService cs = new CourseScoreService();
        System.out.println(JSON.toJSONString(cs.findAllFailScore(username)));
        response.getWriter().println(JSON.toJSONString(cs.findAllFailScore(username)));
        cs.closeCon();
    }
}